<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Action extends MY_Controller {

	function __construct()
	{
		parent::__construct();
		
		
	}

	function index()
	{
		show_404();
	}
	
	function votearticleup()
	{
		if ($this->uri->segment(3) === FALSE)
		{
			show_404();
		}

		$articleID = $this->uri->segment(3);

		$res = $this->articles->vote_up($articleID);

		if($res)
		{
			echo "Your vote has been casted. Thank you for your contribution.";
		}
		else
		{
			echo "Error with vote";
		}
	}	
	
	function flagarticle()
	{
		if ($this->uri->segment(3) === FALSE)
		{
			show_404();
		}		
		
		if ($this->uri->segment(4) === FALSE)
		{
			show_404();
		}
		$desc = FALSE;
		if(isset($_POST['flag_msg']))
		{
			$desc = $_POST['flag_msg'];
		}
		$articleID = $this->uri->segment(3);
		$flagName = $this->uri->segment(4);

		$res = $this->articles->mark_article_flag_action($articleID, 0, $flagName, $desc, 1);
		
		if($res)
		{
			echo "Your flag is marked. Author will have a chance to respond.";
		}
		else
		{
			echo "Error with vote";
		}
	}
	
	function flagaction()
	{
		$articleID = $this->uri->segment(3);
		$flagID = $this->uri->segment(4);
		$nextEventID = $this->uri->segment(5);
		
		$desc = FALSE;
		if(isset($_POST['flag_msg']))
		{
			$desc = $_POST['flag_msg'];
		}
		
		$res = $this->articles->mark_article_flag_action($articleID, $flagID, 0, $desc, $nextEventID);
		
		if($res)
		{
			echo "Your action is marked. The other party will have a chance to respond.";
		}
		else
		{
			echo "Error while performing action. ";
		}
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */